using System;

namespace Open.Data.Persistence
{
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
    public class ColumnAttribute : Attribute
    {
        //Constructors
        public ColumnAttribute() : base() { }
    }

    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
    public abstract class ColumnsAttribute : Attribute
    {
        //Constructors
        public ColumnsAttribute(string columns) : base()
        {
            Columns = columns;
        }

        //Properties
        public string Columns { get; set; }
    }

    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
    public class IndexAttribute : ColumnAttribute, IIndexAttribute 
    {
        //Constructors
        public IndexAttribute() : base() { }
        public IndexAttribute(bool unique) : base() 
        {
            Unique = unique;
        }

        public bool Unique { get; set; }
    }

    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
    public class IndexColumnsAttribute : ColumnsAttribute, IIndexAttribute
    {
        //Constructors
        public IndexColumnsAttribute(string columns) : base(columns) { }
        public IndexColumnsAttribute(string columns, bool unique) : base(columns)
        {
            Unique = unique;
        }
        public bool Unique { get; set; }
    }

    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
    public class UniqueIndexAttribute : IndexAttribute
    {
        //Constructors
        public UniqueIndexAttribute() : base(true) { }
    }

    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
    public class UniqueIndexColumnsAttribute : IndexColumnsAttribute
    {
        //Constructors
        public UniqueIndexColumnsAttribute(string columns) : base(columns, true) { }
    }

    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
    public class PrimaryKeyAttribute : ColumnAttribute, IPrimaryKeyAttribute
    {
        //Constructors
        public PrimaryKeyAttribute() : base() { }
    }

    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
    public class PrimaryKeysAttribute : ColumnsAttribute, IPrimaryKeyAttribute
    {
        //Constructors
        public PrimaryKeysAttribute(string columns) : base(columns) { }
    }

    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
    public class ForeignKeyAttribute : ColumnAttribute, IReferenceAttribute
    {
        //Constructors
        public ForeignKeyAttribute(Type reference) : base() 
        {
            Reference = reference;
        }

        public Type Reference { get; set; }
    }

    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
    public class ForeignKeysAttribute : ColumnsAttribute, IReferenceAttribute
    {
        //Constructors
        public ForeignKeysAttribute(string columns, Type type) : base(columns) 
        {
            Reference = type;
        }

        public Type Reference { get; set; }
    }
}
